const app = require("../app.js")

function getUser() {
  var user = tt.getStorageSync("USER_INFO");
  return user;
}

function saveUser(user) {
  tt.setStorageSync("USER_INFO", user);
}

/**
 * 退出登录
 *
 */
function exit(){
  tt.clearStorage();
}

//进入需要登录的页面
function startPage(url,isCheck=true){
  if(isCheck){
    let userBean =getUser();
    if(!userBean||!userBean.consumerId){
      tt.navigateTo({
        url: '../login/login',
      })
      return;
    }
  }
  tt.navigateTo({
    url: url
  })
}

module.exports = {
  getUser,
  saveUser,
  exit,
  startPage
}